﻿using Xacml.Core;
using System;
using System.Xml;

namespace Xacml.Core.Context
{
  public class RequestElement : RequestElementReadWrite
  {
    public override SubjectCollectionReadWrite Subjects
    {
      get
      {
        return (SubjectCollectionReadWrite) new SubjectCollection(base.Subjects);
      }
      set
      {
        throw new NotSupportedException();
      }
    }

    public override ResourceCollectionReadWrite Resources
    {
      get
      {
        return (ResourceCollectionReadWrite) new ResourceCollection(base.Resources);
      }
      set
      {
        throw new NotSupportedException();
      }
    }

    public override ActionElementReadWrite Action
    {
      get
      {
        return (ActionElementReadWrite) new ActionElement(new AttributeCollection(base.Action.Attributes), base.Action.SchemaVersion);
      }
      set
      {
        throw new NotSupportedException();
      }
    }

    public override EnvironmentElementReadWrite Environment
    {
      get
      {
        if (base.Environment != null)
          return (EnvironmentElementReadWrite) new EnvironmentElement(new AttributeCollection(base.Environment.Attributes), base.Environment.SchemaVersion);
        return (EnvironmentElementReadWrite) null;
      }
      set
      {
        throw new NotSupportedException();
      }
    }

    public override bool IsReadOnly
    {
      get
      {
        return true;
      }
    }

    public RequestElement(SubjectCollection subjects, ResourceCollection resources, ActionElement action, EnvironmentElement environment, XacmlVersion schemaVersion)
      : base((SubjectCollectionReadWrite) subjects, (ResourceCollectionReadWrite) resources, (ActionElementReadWrite) action, (EnvironmentElementReadWrite) environment, schemaVersion)
    {
    }

    public RequestElement(XmlReader reader, XacmlVersion schemaVersion)
      : base(reader, schemaVersion)
    {
    }
  }
}
